home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
-
- $HTTPD_NEWSHOME="/usr1/paul/news" ;
- $HTTPD_HOME="/usr1/paul/httpd" ;
- $GLIMPSE_LOC = "/usr/paul/bin/glimpse";
-
- # No configuration is needed below
- print "Content-type: text/html\n\n";
- $idxfile="$HTTPD_NEWSHOME/groups/articles.db";
- # some beautiful piece of paranoia...
- $idxfile =~ s/\'/\\\'/;
-
- # Ensure that Glimpse is available on this machine
- if (!-x $GLIMPSE_LOC) {
- #
- # Glimpse was not found
- # Report a useful message
- #
- print <<'EOM' ;
- <HEAD>
- <TITLE>Glimpse not found</TITLE>
- </HEAD>
- <BODY>
- <H1>Glimpse not found</H1>
-
- This program relies on <CODE>Glimpse</CODE> search tool.
- If it is installed, please set the correct path in the script file.
- Otherwise obtain the latest version from
- <A HREF="file://ftp.cs.arizona.edu/glimpse">ftp.cs.arizona.edu</A>
- </BODY>
- EOM
- &diag_exit;
- }
- if (!-r $idxfile) {
- print "<TITLE>Cannot open articles database</TITLE>\n";
- print "<H1>Cannot open articles database</H1>\n";
- print "Cannot open $idxfile: $!\n";
- }
-
- # To support an ISINDEX type search, set query string if given
- # an argument on the command line
- $prefix="case=on&query=" if ( $#ARGV >= 0 );
-
- $query = $ENV{'QUERY_STRING'};
-
- $query =~ s/\'//g;
- # Strip the variables out from the query string,
- # and assign them into variables, prefixed by 'QS_'
- @qvars = split( /\&/, $prefix . $query );
- foreach (@qvars) {
- split(/=/);
- $fname = $_[0];
- $fvalue = $_[1];
- $cmd = "\$QS_$fname = '$fvalue';" ;
- # print ">>>",$cmd,"\n";
- $cmd = eval $cmd if ( $fname =~ /^[a-z_A-Z]\w*$/ );
- }
- $QS_query =~ s|\+| |g;
- $QS_query =~ s|%(\w\w)|sprintf("%c", hex($1))|ge;
- $pquery = $QS_query;
- $QS_query =~ s|\'|\'\"\'\"\'|g;
-
- $OPT_errors="-$QS_errors" if $QS_errors =~ /^[0-8]$/;
- $OPT_errors="-B" if $QS_errors =~ /^Best\+match$/;
- $OPT_case="-i" if $QS_case =~ /^on$/;
- $OPT_whole="-w" unless $QS_whole =~ /^on$/;
-
- if ($QS_maxlines =~ /\d+/) {
- $maxlines = $& + 0;
- } else {
- $maxlines = 200;
- }
-
- # Check that a query has been made
- if (!$QS_query) {
- print "<TITLE>Search for news articles parameter</TITLE>\n";
- print "<H1>Search for news articles parameter</H1>\n";
- print "Please specify e-mail address of the author, ";
- print "article ID, subject line, date, or combination of those\n";
- print "<ISINDEX>\n";
- exit;
- }
-
- print "<HEAD><TITLE>Result for query \"$pquery\"\n";
- print "</TITLE></HEAD><BODY>\n";
- print "<H1>Result for query \"$pquery\"</H1><HR>\n";
-
- $cmd = "exec $GLIMPSE_LOC $OPT_case $OPT_whole $OPT_errors " .
- "'$QS_query' $idxfile |";
- open(GOUT, $cmd );
- $artcount = 0;
- print "<OL>";
- line: while (<GOUT>) {
- chop;
- $artcount++;
- if ($artcount > $maxlines) {
- $artcount = "at least $artcount";
- print "<LI>Limit of $maxlines articles exceeded";
- last line;
- }
- s/\&/\&/;
- s/\</\</;
- s/\>/\>/;
- split(/\t/);
- print "<LI><A HREF=\"/cgi-bin/article$_[0]\">\n";
- print "$_[3] <I>$_[5]</I><BR>$_[4]</A>\n";
- }
- print "</OL><HR>Total of $artcount articles.\n";
- print "</BODY>\n";
- close(GOUT);
-